﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using SIPO.Library.DataAccess.Report;
using SIPO.Library.DomainObject.Transaction;
using SIPO.Library.DataAccess.Administration.Catalog;
using SIPO.Library.DomainObject.Administration.Catalog;
using SIPO.Library.DataAccess.Transaction;
using SIPO.Web.Support;
using Microsoft.Reporting.WebForms;
using System.Threading.Tasks;
using System.Drawing;

namespace SIPO.Web.lists.Report
{
    public partial class rptPenerimaanlist : BasePage
    {
        rptDashboardRepo recDashboard = new rptDashboardRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);
        
  
        protected override void OnLoad(EventArgs e)
        {

            if (!IsPostBack)
            {
                DataTable ddl = recDashboard.PeriodeLaporan("period", "v_lap_komp_penerimaan_persektor");
                for (int i = 0; ddl.Rows.Count > i; i++)
                {
                    if (ddl.Rows[i][0].ToString() != "")
                    {
                        ddlVersi.Items.Add(ddl.Rows[i][0].ToString());
                    }
                }
                if (ddlVersi.Items.Count != 0)
                {
                    ddlVersi.SelectedValue = DateTime.Now.Year.ToString();
                }
            }
                    try
                {
                    DataTable dt = recDashboard.GetLaporan(ddlVersi.SelectedValue, "v_lap_komp_penerimaan_persektor","Period");

                    rsViewer.Reset();
                    string path = "~/reportviewer/DsbPenerimaan.rdlc";
                    rsViewer.LocalReport.ReportPath = Server.MapPath(path);
                    ReportDataSource rds = new ReportDataSource();
                    rds.Name = "DataSet1";
                    rds.Value = dt;
                    ReportParameter p1 = new ReportParameter("Title", "Komposisi Penerimaan Tahun " + ddlVersi.SelectedValue);
                    //ReportParameter p2 = new ReportParameter("PeriodeThn1", txtPeriode.Substring(6, 4));
                    //ReportParameter p3 = new ReportParameter("PeriodeThn2", paramdate3.ToString());
                    this.rsViewer.LocalReport.SetParameters(new ReportParameter[] { p1 });

                    rsViewer.LocalReport.DataSources.Clear();
                    rsViewer.LocalReport.DataSources.Add(rds);
                    rsViewer.LocalReport.Refresh();
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message);
                }
            
        }
        

        //protected void Button1_Click(object sender, EventArgs e)
        //{




        //    try
        //    {
        //        DataTable dt = recDashboard.GetLaporan(ddlVersi.SelectedValue,"v_lap_komp_penerimaan_persektor");

        //        rsViewer.Reset();
        //        string path = "~/reportviewer/DsbPenerimaan.rdlc";
        //        rsViewer.LocalReport.ReportPath = Server.MapPath(path);
        //        ReportDataSource rds = new ReportDataSource();
        //        rds.Name = "DataSet1";
        //        rds.Value = dt;
        //        ReportParameter p1 = new ReportParameter("Title", "Periode " + ddlVersi.SelectedValue);
        //        //ReportParameter p2 = new ReportParameter("PeriodeThn1", txtPeriode.Substring(6, 4));
        //        //ReportParameter p3 = new ReportParameter("PeriodeThn2", paramdate3.ToString());
        //        this.rsViewer.LocalReport.SetParameters(new ReportParameter[] { p1 });

        //        rsViewer.LocalReport.DataSources.Clear();
        //        rsViewer.LocalReport.DataSources.Add(rds);
        //        rsViewer.LocalReport.Refresh();
        //    }
        //    catch (Exception ex)
        //    {
        //        Response.Write(ex.Message);
        //    }
            



            
          
            
            
               
            

        //}


    }
}